home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / VirtualFile / FileOfFiles.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  2.3 KB  |  86 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        FileOfFiles.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __FILEOFFILES__
  15. #define __FILEOFFILES__
  16.  
  17. #ifndef __VIRTUALFILE__
  18. #include "VirtualFile.h"
  19. #endif
  20.  
  21. #ifndef    __OBJECTLIST__
  22. #include "ObjectList.h"
  23. #endif
  24.  
  25. #pragma push
  26. #pragma segment FileOfFiles
  27.  
  28. /***********************************|****************************************/
  29.  
  30. class TFileOfFiles : public TVirtualFile
  31. {
  32. public:
  33.             TFileOfFiles();
  34.     virtual ~TFileOfFiles();
  35.  
  36.             unsigned long             NumFiles() const;
  37.             TVirtualFile*             GetIndexFile ( unsigned long index ) const;
  38.             unsigned long             GetFileIndex( const TVirtualFile* ) const;
  39.  
  40.             OSErr                     AppendFile ( TVirtualFile* );
  41.             OSErr                     InsertFile ( TVirtualFile*, unsigned long );
  42.             TVirtualFile*             RemoveIndexFile ( unsigned long );
  43.  
  44.     virtual OSErr                     ReadData ( void*, long& );
  45.     virtual OSErr                     WriteData ( const void*, long& );
  46.  
  47.     virtual OSErr                     SetEnd ( long );
  48.     virtual OSErr                     GetEnd ( long& ) const;
  49.  
  50.     virtual OSErr                     SetPosition ( short posMode, long posOff );
  51.     virtual OSErr                     GetPosition ( long& ) const;
  52.  
  53.             OSErr                    Consolidate ();    // integrates the subfiles into a single subfile
  54.     
  55.     virtual ostream&                 operator >> ( ostream& ) const;
  56.  
  57.             void                    InvalidateCache ();
  58.  
  59. private:    OSErr                    GetSubFile ( unsigned long position, TVirtualFile*& subFile, long& offsetInSubfile, unsigned long& subFileIndex, Boolean makeFiles );
  60.             OSErr                    GetNextCacheFile ();
  61.             unsigned long            GetEnd () const;
  62.             
  63.             TVirtualFileList*         fFileList;
  64.             long                    fPosition;
  65.  
  66.             OSErr                    ValidateCache ( Boolean makeFile );
  67.  
  68.             TVirtualFile*            fCacheFile;
  69.             long                    fCacheOffset;
  70.             unsigned long            fCacheIndex;
  71.             
  72.     friend class TCacheCache;
  73. };
  74.  
  75. /***********************************|****************************************/
  76.  
  77. inline unsigned long TFileOfFiles::NumFiles() const { return fFileList->Count(); }
  78. inline TVirtualFile* TFileOfFiles::GetIndexFile(unsigned long index) const { return fFileList->Get(index); }
  79. inline unsigned long TFileOfFiles::GetFileIndex(const TVirtualFile* aFile) const { return fFileList->Find(aFile); }
  80.  
  81. /***********************************|****************************************/
  82.  
  83. #pragma pop
  84.  
  85. #endif    // defined __FILEOFFILES__
  86.